 //1.公用样式
 require('../../assets/css/index.js')
 //当前页面样式
 require('./courseDetails.less')

    //2.公用js
let dom=require('../../utils/dom.js');
let https=require('../../utils/https.js');
let local=require('../../utils/local.js');
    //3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function(){
    let coach=dom.getById('.coach');
    let header=dom.getById('header');
    let go=dom.getById('#go');

    https.get('/api/train/courseDetail?id='+local.get('id'),function(res){
        console.log(res.fragments);
        let imgs=res.data.imgurl
        header.innerHTML=`
        <img src="${https.BASE_URL+imgs}" alt="">
        <div id="pas" class="iconfont icon-31fanhui1"></div>
        <div id="but" class="iconfont icon-24gf-play">
        <div class="txt">视屏预览</div>
        </div>
        ` 
    });
    header.addEventListener('click',function(e){
        let id=e.target.id;
        if(id=='but'){
         https.get('/api/train/courseDetail?id='+local.get('id'),function(res){
            let video=res.data.fragments;
            let videoUrl=video[2].videoUrl

            console.log(video);
            
            header.innerHTML=`
            <video src="${https.BASE_URL+videoUrl}" controls></video>
            <div id="pas" class="iconfont icon-31fanhui1"></div>
            ` 
        });          
        }
        if(id=='pas'){
            location.href='cour.html'
        }
    })
    go.addEventListener('click',function(){
        location.href='courseDrill.html'
    })



    
})